import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { fileURLToPath,URL } from 'url'
import { visualizer } from 'rollup-plugin-visualizer';
import { autoComplete, Plugin as importToCDN } from 'vite-plugin-cdn-import'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    visualizer({ open: true }),
    importToCDN({
      modules: [
        autoComplete('axios'),
        autoComplete('lodash'),
        {
          name:"vue",
          var:"Vue",
          path:"https://unpkg.com/vue@3.3.8"
        },
        //cdn引入vue-demi
        {
          name: 'vue-demi',
          var: 'VueDemi',
          path: 'https://unpkg.com/vue-demi@0.14.7'
        },
        {
          name:"element-plus",
          var:"ElementPlus",
          path:"https://unpkg.com/element-plus@2.4.3",
          css:"https://unpkg.com/element-plus/dist/index.css"
        },
        {
          name:"vue-router",
          var:"VueRouter",
          path:"https://unpkg.com/vue-router@4.2.5"
        },
        {
          name:"pinia",
          var:"Pinia",
          path:"https://unpkg.com/pinia@2.1.7"
        }
      ]
  }),
  ],
  resolve: {
    alias: {
      '@':fileURLToPath(new URL('./src',import.meta.url))
    }
  }
})
